{
  "name": "Case 14 – CSR Project Selection",
  "nodes": [
    {
      "name": "On form submission",
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2,
      "position": [0, 0],
      "parameters": {
        "formTitle": "CSR Project Proposal Submission",
        "formDescription": "NGO submits CSR proposal for funding evaluation",
        "formFields": {
          "values": [
            { "fieldLabel": "NGO Name", "requiredField": true },
            { "fieldLabel": "Project Title", "requiredField": true },
            { "fieldLabel": "Email id", "fieldType": "email", "requiredField": true },
            {
              "fieldLabel": "CSR_Proposal",
              "fieldType": "file",
              "acceptFileTypes": ".pdf",
              "requiredField": true
            }
          ]
        }
      }
    },
    {
      "name": "Upload file",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [220, 0],
      "parameters": {
        "inputDataFieldName": "CSR_Proposal",
        "name": "={{ $json['NGO Name'] + '_CSR_Proposal' }}",
        "folderId": "REPLACE_WITH_CSR_PROPOSALS_FOLDER_ID"
      }
    },
    {
      "name": "Download file",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [420, 0],
      "parameters": {
        "operation": "download",
        "fileId": "={{ $json.id }}"
      }
    },
    {
      "name": "Extract CSR Proposal",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [620, 0],
      "parameters": {
        "operation": "pdf"
      }
    },
    {
      "name": "Download CSR Objectives & Evaluation Framework",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [820, 0],
      "parameters": {
        "operation": "download",
        "fileId": "REPLACE_WITH_CSR_OBJECTIVES_FILE_ID"
      }
    },
    {
      "name": "Extract CSR Framework",
      "type": "n8n-nodes-base.extractFromFile",
      "typeVersion": 1,
      "position": [1020, 0],
      "parameters": {
        "operation": "pdf"
      }
    },
    {
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3,
      "position": [220, 260],
      "parameters": {
        "promptType": "define",
        "text": "=CSR Project Proposal:\n{{ $('Extract CSR Proposal').item.json.text }}\n\nCorporate CSR Objectives & Evaluation Framework:\n{{ $('Extract CSR Framework').item.json.text }}",
        "options": {
          "systemMessage": "You are a Corporate CSR Committee Member responsible for allocating CSR funds under statutory and strategic objectives.\n\nYOUR OBJECTIVE:\nSelect CSR projects that deliver measurable social impact, strong governance, and alignment with the company’s CSR focus areas, while minimizing reputational and execution risk.\n\nANALYSIS FRAMEWORK (MANDATORY):\n1. CSR ALIGNMENT – fit with statutory CSR themes (education, healthcare, livelihoods, environment, etc.).\n2. SOCIAL IMPACT – scale, depth, and measurability of beneficiary outcomes.\n3. IMPLEMENTATION CAPABILITY – NGO experience, execution plan, and track record.\n4. GOVERNANCE & COMPLIANCE – statutory compliance, transparency, audit readiness.\n5. RISK & SUSTAINABILITY – operational, reputational, and long-term sustainability risk.\n\nYOU MUST PRODUCE ONE JSON OBJECT WITH EXACTLY THESE FIELDS. ALL FIELDS ARE MANDATORY.\n\nJSON SCHEMA (STRICT):\n{\n  \"NGO_Name\": \"string\",\n  \"Project_Title\": \"string\",\n  \"CSR_Theme\": \"string\",\n  \"Geographic_Focus\": \"string\",\n  \"Funding_Requested_INR_Cr\": \"number\",\n  \"Estimated_Beneficiaries\": \"number\",\n  \"Social_Impact_Potential\": \"Low | Medium | High\",\n  \"Implementation_Capability\": \"Weak | Moderate | Strong\",\n  \"Governance_and_Compliance_Risk\": \"Low | Medium | High\",\n  \"Overall_CSR_Score_out_of_100\": \"number\",\n  \"Funding_Decision\": \"Funded | Declined\",\n  \"CSR_Committee_Remarks\": \"string\"\n}\n\nINSTRUCTIONS:\n- Numeric fields MUST contain numbers only.\n- Do NOT add, remove, or rename fields.\n- Output ONLY valid JSON.\n- IMMEDIATELY call the Google Sheets Append Row tool using this JSON."
        }
      }
    },
    {
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [0, 420],
      "parameters": {
        "model": {
          "mode": "list",
          "value": "gpt-4.1-mini"
        }
      }
    },
    {
      "name": "Append row",
      "type": "n8n-nodes-base.googleSheetsTool",
      "typeVersion": 4,
      "position": [420, 460],
      "parameters": {
        "operation": "append",
        "documentId": "REPLACE_WITH_GOOGLE_SHEET_ID",
        "sheetName": "CSR Project Evaluation Register"
      }
    },
    {
      "name": "Send Email",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [420, 260],
      "parameters": {
        "sendTo": "={{ $('On form submission').item.json['Email id'] }}",
        "subject": "CSR Project Proposal – Funding Decision",
        "message": "={{ 'Dear ' + $('On form submission').item.json['NGO Name'] + ',<br><br>Thank you for submitting your CSR project proposal. It has been reviewed by our CSR Committee, and we will inform you of the funding decision and next steps shortly.<br><br>CSR Committee' }}"
      }
    }
  ],
  "connections": {
    "On form submission": { "main": [[{ "node": "Upload file" }]] },
    "Upload file": { "main": [[{ "node": "Download file" }]] },
    "Download file": { "main": [[{ "node": "Extract CSR Proposal" }]] },
    "Extract CSR Proposal": { "main": [[{ "node": "Download CSR Objectives & Evaluation Framework" }]] },
    "Download CSR Objectives & Evaluation Framework": { "main": [[{ "node": "Extract CSR Framework" }]] },
    "Extract CSR Framework": { "main": [[{ "node": "AI Agent" }]] },
    "OpenAI Chat Model": { "ai_languageModel": [[{ "node": "AI Agent" }]] },
    "Append row": { "ai_tool": [[{ "node": "AI Agent" }]] },
    "AI Agent": { "main": [[{ "node": "Send Email" }]] }
  },
  "active": false
}
